package main

import (
	"gitee.com/simple-set/simple.io/src/event"
	"gitee.com/simple-set/simple.io/src/process/http"
)

type HttpServer struct {
}

func NewHttpServer() *HttpServer {
	return &HttpServer{}
}

func (h *HttpServer) Accept(_ *event.Session) error {
	return nil
}

func (h *HttpServer) Disconnect(_ *event.Session) error {
	return nil
}

func (h *HttpServer) Active(session *event.Session, _ any) (any, error) {
	response := session.GetAttr("response").(*http.Response)
	if _, err := response.Body().WriteString("hello world"); err != nil {
		_ = session.Close()
		return nil, err
	} else {
		return response, nil
	}
}
